const express = require('express');
const router = express.Router();

const {find} = require('../models/question')

const multer  = require('multer')
const {admin} = require("../middleware/admin");
const storage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, './public/uploads/problemData')
    },
    filename: function (req, file, cb) {
        console.log(file)
        cb(null, file.originalname )
    }
})

const upload = multer({ storage: storage })
// let upload = multer({dest: '../uploads/'}); //设置上传的的图片保存目录


router.post('/', admin, upload.single('file'), function(req, res) {
    res.json(req.file)
})

module.exports = router